#pragma once

#include <QOpenGLWidget>

#include <QMouseEvent>
#include <QWheelEvent>
#include <QDesktopWidget>
#include <QScreen>
#include <QtGlobal>
#include <QWindow>

#include <osg/ref_ptr>
#include <osgViewer/GraphicsWindow>
#include <osgViewer/Viewer>
#include <osg/Camera>
#include <osg/ShapeDrawable>
#include <osg/StateSet>
#include <osg/Material>
#include <osgGA/EventQueue>
#include <osgGA/TrackballManipulator>
#include <osgDB/ReadFile>

#include "Axes.h"

class OpenGLWidget : public QOpenGLWidget
{
	Q_OBJECT

public:
	OpenGLWidget(QWidget* parent = 0);
	virtual ~OpenGLWidget();

protected:
	void initData();
	void initCamera();
	void initViewer();

	osg::Group* getData();

protected:

	virtual void initializeGL();

	virtual void resizeGL(int w, int h);

	virtual void paintGL();

	virtual void mouseMoveEvent(QMouseEvent* event);

	virtual void mousePressEvent(QMouseEvent* event);

	virtual void mouseReleaseEvent(QMouseEvent* event);

	virtual void wheelEvent(QWheelEvent* event);

	virtual bool event(QEvent* event);

private:

	osgGA::EventQueue* getEventQueue() const;

	osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> mGraphicsWindow;
	osg::ref_ptr<osgViewer::Viewer> mViewer;
	osg::ref_ptr<Axes> mAxes;
};
